enum METHODS {
    //% block="面诊辨识"
    faceAnalysis,
    //% block="证型辨识"
    tongueAnalysis,
    //% block="体质辨识"
    jiuti,
    //% block="证型辨识+体质辨识"
    tiAnalysis,
    //% block="舌面诊-体质辨识"
    TongueFaCeconstitution,
    //% block="舌面诊-证型+体质辨识"
    TongueFaceAnalysis,
}


//% color="#FFF000" iconWidth=50 iconHeight=40
namespace unihiker_aibayes_analysis{

    //% block="诊断初始化ID[APP_ID]，KEY[APP_KEY]" blockType="command"
    //% APP_ID.shadow="string" APP_ID.def1="032beb189d554d47"
    //% APP_KEY.shadow="string" APP_KEY.def1="56f224a2fee34323b3e170e3b2561c5e"
    export function analysis_init(parameter: any, block: any) {
        let app_id=parameter.APP_ID.code;
        let app_key=parameter.APP_KEY.code;
        Generator.addImport(`from main import Aibayes`)
        Generator.addCode(`print("模型初始化")
aibays = Aibayes(app_id=${app_id}, app_key=${app_key})
`)
    }


    //% block="上传图片[FILENAME]并选择[METHOD]识别" blockType="reporter"
    //% METHOD.shadow="dropdown" METHOD.options="METHODS" METHOD.def1="METHODS.faceAnalysis"
    //% FILENAME.shadow="string" FILENAME.defl="img.png"
    export function pose_detection(parameter: any, block: any) {
        let method=parameter.METHOD.code;
        let filename=parameter.FILENAME.code;
        Generator.addCode(`aibays.normal_api(method="${method}", imgpath=${filename})`)
    }

}
